#include<iostream>
namespace sptr
{
	template<class T>
	class myauto_ptr
	{
	public:
		myauto_ptr(T* ptr)
			:_ptr(ptr)
		{}
		~myauto_ptr()
		{
			if (_ptr)
			{
				cout << "delete: " << _ptr << endl;
				delete _ptr;
				_ptr = nullptr;
			}
		}
		myauto_ptr(myauto_ptr<T>& ap)
			:_ptr(ap._ptr)
		{
			ap._ptr = nullptr;
		}
		myauto_ptr& operator=(myauto_ptr<T>& ap)
		{
			if (this != &ap)
			{
				delete _ptr;
				_ptr = ap._ptr;
				ap._ptr = nullptr;
			}
			return *this;
		}
		T& operator*()
		{
			return *_ptr;
		}
		T* operator->()
		{
			return _ptr;
		}
		 
	private:
		T* _ptr;
	};
}

